import Mock from "mockjs";
const Random = Mock.Random

let Result = {
    code: 200,
    msg: "操作成功",
    data: null
}
Mock.mock("/self/login","post",(res)=>{
    console.log(res.body)
    Result.data = null
    return Result;
})

Mock.mock("/self/registered","post",(res)=>{
    console.log(res.body)
    Result.data = null
    return Result;
})

Mock.mock("/sys/menu","get",()=>{
    Result.data = [
        {
            id: 1,
            index: '1',
            name: "用户",
            EName: "User",
            path: "/user",
            children: [
                {
                    id: 1.1,
                    index: '1-1',
                    name: "个人信息",
                    EName: "SelfInfo",
                    path: "/selfInfo",
                },
                {
                    id: 1.2,
                    index: '1-2',
                    name: "管理员管理",
                    EName: "Administrator",
                    path: "/displayList",
                    query: "administrator"
                },
                {
                    id: 1.3,
                    index: '1-3',
                    name: "用户管理",
                    EName: "GeneralUser",
                    path: "/displayList",
                    query: "generalUser"
                }
            ]
        },
        {
            id: 2,
            index: '2',
            name: "图书",
            EName: "Book",
            path: "/book",
            children: [
                {
                    id: 2.1,
                    index: '2-1',
                    name: "图书管理",
                    EName: "Book",
                    path: "/displayList",
                    query: "book"
                },
                {
                    id: 2.2,
                    index: '2-2',
                    name: "图书类型管理",
                    EName: "BookType",
                    path: "/displayList",
                    query: "bookType"
                },
            ]
        },
        {
            id: 3,
            index: '3',
            name: "借阅",
            EName: "Borrow",
            path: "/borrow",
            children: [
                {
                    id: 3.1,
                    index: '3-1',
                    name: "借阅管理",
                    EName: "Borrow",
                    path: "/displayList",
                    query: "borrow"
                },
            ]
        },
        {
            id: 4,
            index: '4',
            name: "权限",
            EName: "Authority",
            path: "/authority",
            children: [
                {
                    id: 4.1,
                    index: '4-1',
                    name: "用户角色管理",
                    EName: "Role",
                    path: "/displayList",
                    query: "role"
                },
                {
                    id: 4.2,
                    index: '4-2',
                    name: "权限管理",
                    EName: "Permissions",
                    path: "/displayList",
                    query: "permissions"
                },
                {
                    id: 4.3,
                    index: '4-3',
                    name: "菜单管理",
                    EName: "Menu",
                    path: "/displayList",
                    query: "menu"
                }
            ]
        }
    ]
    return Result;
})


const userAdminList = Mock.mock({
    "array": [
        {
            "data|5-10": [
                {
                    "adminId": "@id",
                    "adminName": '@first',
                    "adminPassword": "@guid",
                    "adminType|+1": [1,2,3]
                }
            ],
            "pages": 20,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "adminId": "@id",
                    "adminName": '@first',
                    "adminPassword": "@guid",
                    "adminType|+1": [1,2,3]
                }
            ],
            "pages": 20,
            "nowPage": 2
        },
        {
            "data|5-10": [
                {
                    "adminId": "@id",
                    "adminName": '@first',
                    "adminPassword": "@guid",
                    "adminType|+1": [1,2,3]
                }
            ],
            "pages": 20,
            "nowPage": 3
        }
    ]
})

Mock.mock(/\/user\/admin\/read\?page=\d+/,"get",() => {
    //console.log(userAdminList.array[Random.integer(0,2)]);
    Result.data = userAdminList.array[Random.integer(0,2)];
    return Result
})

Mock.mock("/user/admin/top","get",() => {
    //Result.data = userAdminTopList.array;
    Result.data = [
        {
            prop: "adminId",
            label: "ID",
            editable: false,
            type: "default"
        },
        {
            prop: "adminName",
            label: "账户名",
            editable: true,
            type: "default"
        },
        {
            prop: "adminPassword",
            label: "密码",
            editable: true,
            type: "password"
        },
        {
            prop: "adminType",
            label: "权限信息",
            editable: true,
            type: "list",
            listData: [
                {
                    id: 1,
                    name: "超级管理员",
                },
                {
                    id: 2,
                    name: "楼层管理员",
                },
                {
                    id: 3,
                    name: "普通管理员",
                }
            ]
        }
    ];
    return Result
})

Mock.mock("/user/admin/update","post",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

Mock.mock(/\/user\/admin\/delete\?id=\d+/,"get",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

const insertId = Mock.mock("@id")
Mock.mock("/user/admin/insert","post",(res) => {
    //console.log(JSON.parse(res.body));
    let obj = JSON.parse(res.body)
    obj.adminId = insertId;
    Result.data = obj;
    return Result
})


const userUserList = Mock.mock({
    "array": [
        {
            "data|5-10": [
                {
                    "userId": "@id",
                    "username": '@first',
                    "password": "@guid",
                    "sex|+1": [1,2] ,
                    "email": "@email",
                    "phone": "@integer(1111111111,99999999999)",
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "userId": "@id",
                    "username": '@first',
                    "password": "@guid",
                    "sex|+1": [1,2] ,
                    "email": "@email",
                    "phone": "@integer(1111111111,99999999999)",
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "userId": "@id",
                    "username": '@first',
                    "password": "@guid",
                    "sex|+1": [1,2] ,
                    "email": "@email",
                    "phone": "@integer(1111111111,99999999999)",
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        }
    ]
})

Mock.mock(/\/user\/read\/\d+/,"get",() => {
    //console.log(userUserList.array[Random.integer(0,2)]);
    Result.data = userUserList.array[Random.integer(0,2)];
    return Result
})

Mock.mock("/top/user","get",() => {
    Result.data = [
        {
            prop: "userId",
            label: "ID",
            editable: false,
            type: "default"
        },
        {
            prop: "username",
            label: "用户名",
            editable: true,
            type: "default"
        },
        {
            prop: "password",
            label: "密码",
            editable: true,
            type: "password"
        },
        {
            prop: "sex",
            label: "性别",
            editable: true,
            type: "list",
            listData: [
                {
                    id: 1,
                    name: "男",
                },
                {
                    id: 2,
                    name: "女",
                }
            ]
        },
        {
            prop: "email",
            label: "邮箱",
            editable: true,
            type: "default"
        },
        {
            prop: "phone",
            label: "手机号",
            editable: true,
            type: "default"
        },
        {
            prop: "createdAt",
            label: "创建时间",
            editable: false,
            type: "default"
        },
        {
            prop: "updatedAt",
            label: "更新时间",
            editable: false,
            type: "default"
        }
    ]
    return Result
})

Mock.mock("/user/user/update","post",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

Mock.mock(/\/user\/user\/delete\?id=\d+/,"get",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})
Mock.mock("/user/user/insert","post",(res) => {
    //console.log(JSON.parse(res.body));
    let obj = JSON.parse(res.body)
    obj.userId = insertId;
    Result.data = obj;
    return Result
})


const bookList = Mock.mock({
    "array": [
        {
            "data|5-10": [
                {
                    "bookId": "@id",
                    "title": '@ctitle',
                    "author": "@first",
                    "language|+1": ["英语", "中文", "阿拉伯语"],
                    "publisher": "@name",
                    "publicationDate": "@date @time",
                    "price|1-100.1-10": 1,
                    "isbn": "@guid",
                    "summary": "@ctitle",
                    "imageUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "typeId|+1": [1,2,3,4,5] ,
                    "advertiseImgUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "bookId": "@id",
                    "title": '@ctitle',
                    "author": "@first",
                    "language|+1": ["英语", "中文", "阿拉伯语"],
                    "publisher": "@name",
                    "publicationDate": "@date @time",
                    "price|1-100.1-10": 1,
                    "isbn": "@guid",
                    "summary": "@ctitle",
                    "imageUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "typeId|+1": [1,2,3,4,5] ,
                    "advertiseImgUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "bookId": "@id",
                    "title": '@ctitle',
                    "author": "@first",
                    "language|+1": ["英语", "中文", "阿拉伯语"],
                    "publisher": "@name",
                    "publicationDate": "@date @time",
                    "price|1-100.1-10": 1,
                    "isbn": "@guid",
                    "summary": "@ctitle",
                    "imageUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "typeId|+1": [1,2,3,4,5] ,
                    "advertiseImgUrl": Random.image('200x100', '#50B347', '#FFF', 'Mock.js'),
                    "createdAt": "@date @time",
                    "updatedAt": "@date @time",
                }
            ],
            "pages": 20,
            "nowPage": 1
        }
    ]
})

Mock.mock(/\/book\/book\/read\?page=\d+/,"get",() => {
    //console.log(userUserList.array[Random.integer(0,2)]);
    Result.data = bookList.array[Random.integer(0,2)];
    return Result
})

Mock.mock("/book/book/top","get",() => {
    Result.data = [
        {
            prop: "bookId",
            label: "ID",
            editable: false,
            type: "default"
        },
        {
            prop: "title",
            label: "书籍标题",
            editable: true,
            type: "default"
        },
        {
            prop: "author",
            label: "作者",
            editable: true,
            type: "default"
        },
        {
            prop: "language",
            label: "书籍语言",
            editable: true,
            type: "default"
        },
        {
            prop: "publisher",
            label: "出版商",
            editable: true,
            type: "default"
        },
        {
            prop: "price",
            label: "价格",
            editable: true,
            type: "default"
        },
        {
            prop: "isbn",
            label: "书籍ISBN号",
            editable: true,
            type: "default"
        },
        {
            prop: "summary",
            label: "书籍简介",
            editable: true,
            type: "default"
        },
        {
            prop: "imageUrl",
            label: "封面图片",
            editable: true,
            type: "images"
        },
        {
            prop: "advertiseImgUrl",
            label: "宣传图片",
            editable: true,
            type: "images"
        },
        {
            prop: "typeId",
            label: "类别",
            editable: true,
            type: "list",
            listData: [
                {
                    id: 1,
                    name: "科技类",
                },
                {
                    id: 2,
                    name: "文学类",
                },
                {
                    id: 3,
                    name: "地理类",
                }
            ]
        },
        {
            prop: "publicationDate",
            label: "出版时间",
            editable: false,
            type: "default"
        },
        {
            prop: "createdAt",
            label: "创建时间",
            editable: false,
            type: "default"
        },
        {
            prop: "updatedAt",
            label: "更新时间",
            editable: false,
            type: "default"
        }
    ]
    return Result
})

Mock.mock("/book/book/update","post",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

Mock.mock(/\/book\/book\/delete\?id=\d+/,"get",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})
Mock.mock("/book/book/insert","post",(res) => {
    //console.log(JSON.parse(res.body));
    let obj = JSON.parse(res.body)
    obj.userId = insertId;
    Result.data = obj;
    return Result
})


const bookTypeList = Mock.mock({
    "array": [
        {
            "data|5-10": [
                {
                    "typeId": "@id",
                    "typeName": '@ctitle',
                }
            ],
            "pages": 1,
            "nowPage": 1
        }
    ]
})

Mock.mock(/\/book\/bookType\/read\?page=\d+/,"get",() => {
    //console.log(userUserList.array[Random.integer(0,2)]);
    Result.data = bookTypeList.array[0];
    return Result
})

Mock.mock("/book/bookType/top","get",() => {
    Result.data = [
        {
            prop: "typeId",
            label: "ID",
            editable: false,
            type: "default"
        },
        {
            prop: "typeName",
            label: "类型名",
            editable: true,
            type: "default"
        }
    ]
    return Result
})

Mock.mock("/book/bookType/update","post",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

Mock.mock(/\/book\/bookType\/delete\?id=\d+/,"get",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})
Mock.mock("/book/bookType/insert","post",(res) => {
    //console.log(JSON.parse(res.body));
    let obj = JSON.parse(res.body)
    obj.userId = insertId;
    Result.data = obj;
    return Result
})


const orderList = Mock.mock({
    "array": [
        {
            "data|5-10": [
                {
                    "orderId": "@id",
                    "bookId": "@id",
                    "userId": "@id",
                    "serial": "@guid",
                    "quantity|1-20": 1,
                    "price|1-200.1-2": 1,
                    "total|1-200.1-2": 1,
                    "state|+1": [1,2,3,4,5],
                    "payTime": '@datetime',
                    "deliveryTime": '@datetime',
                    "receiptTime": '@datetime',
                    "confirmTime": '@datetime',
                    "createdAt": '@datetime',
                    "updatedAt": '@datetime',
                }
            ],
            "pages": 10,
            "nowPage": 1
        },
        {
            "data|5-10": [
                {
                    "orderId": "@id",
                    "bookId": "@id",
                    "userId": "@id",
                    "serial": "@guid",
                    "quantity|1-20": 1,
                    "price|1-200.1-2": 1,
                    "total|1-200.1-2": 1,
                    "state|+1": [1,2,3,4,5],
                    "payTime": '@datetime',
                    "createdAt": '@datetime',
                    "updatedAt": '@datetime',
                }
            ],
            "pages": 20,
            "nowPage": 1
        }
    ]
})

Mock.mock(/\/order\/order\/read\?page=\d+/,"get",() => {
    //console.log(userUserList.array[Random.integer(0,2)]);
    Result.data = orderList.array[Random.integer(0,1)];
    return Result
})

Mock.mock("/order/order/top","get",() => {
    Result.data = [
        {
            prop: "orderId",
            label: "orderID",
            editable: false,
            type: "default"
        },
        {
            prop: "bookId",
            label: "bookID",
            editable: false,
            type: "default"
        },
        {
            prop: "userId",
            label: "userID",
            editable: false,
            type: "default"
        },
        {
            prop: "serial",
            label: "订单序列号",
            editable: false,
            type: "default"
        },
        {
            prop: "quantity",
            label: "书籍数量",
            editable: true,
            type: "number"
        },
        {
            prop: "price",
            label: "书籍单价",
            editable: false,
            type: "default"
        },
        {
            prop: "total",
            label: "订单总金额",
            editable: false,
            type: "default"
        },
        {
            prop: "state",
            label: "订单状态",
            editable: true,
            type: "list",
            listData: [
                {
                    id: 1,
                    name: "已付款"
                },
                {
                    id: 2,
                    name: "已发货"
                },
                {
                    id: 3,
                    name: "已送达"
                },
                {
                    id: 4,
                    name: "已签收"
                },
                {
                    id: 5,
                    name: "已完成"
                }
            ]
        },
        {
            prop: "payTime",
            label: "支付时间",
            editable: false,
            type: "default"
        },
        {
            prop: "createdAt",
            label: "创建时间",
            editable: false,
            type: "default"
        },
        {
            prop: "updatedAt",
            label: "更新时间",
            editable: false,
            type: "default"
        }
    ]
    return Result
})

Mock.mock("/order/order/update","post",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})

Mock.mock(/\/order\/order\/delete\?id=\d+/,"get",(res) => {
    Result.data = "success";
    console.log(res);
    return Result
})
Mock.mock("/order/order/insert","post",(res) => {
    //console.log(JSON.parse(res.body));
    let obj = JSON.parse(res.body)
    obj.userId = insertId;
    Result.data = obj;
    return Result
})





















Mock.mock("/self/avatar/upload","post",(res)=>{
    console.log(res)
    Result.data = 'ok';
    return Result
})

Mock.mock("/self/info","get",()=>{
    Result.data = {
        id: 1,
        selfName: "懒散人",
        selfPassword: "Lqg5201314",
        selfAvatar: "http://139.196.218.60:9000/icon/QQ.png",
        motto: "上有天，下有地，中间站着你自己，做一天人，尽一天人事儿。",
        say: "幸福就是珍惜已拥有的一切，珍惜现在爱你的人，珍惜现在你爱的人。缘分来之不易，幸福奢侈，可遇不可求。能够拥有，即是幸福。如果你想生活得快乐，请一定要记得珍惜。"
    }
    return Result
})

Mock.mock("/self/update","put",(res)=>{
    console.log(res)
    Result.data = 'ok';
    return Result
})

Mock.mock("/self/connect/delete/1","delete",()=>{
    Result.data = "success"
    Result.code = 200;
    Result.msg = "操作成功"
    return Result
})

// Mock.mock("/self/connect/delete/2","delete",()=>{
//     Result.code = 404;
//     Result.msg = "出错了出错了"
//     Result.data = "null"
//     return Result
// })

Mock.mock("/self/connect/update","put",(res)=>{
    console.log(res.body)
    Result.data = "success"
    return Result
})

Mock.mock("/self/connect/insert","post",(res)=>{
    console.log(res.body)
    Result.data = {
        id: 7
    }
    return Result
})

Mock.mock("/sys/focusNews/list","get",() => {
    Result.data = [
        {
            id: 1,
            name: "红色纪念馆之旅",
            url: "https://www.sohu.com/a/499727472_429139?code=3f167c5d584dd22331811a0d65dd857&spm=smpc.news-home.top-news1.2.1636287723804Kv7GyMX&_f=index_chan08cpc_1_0",
            img: "https://p0.itc.cn/images01/20211107/b3c16bccdbc24f2a831280c4cfc5fb92.jpeg",
        },
        {
            id: 2,
            name: "疫情",
            url: "https://www.sohu.com/a/499660991_114988?spm=smpc.news-home.top-news2.1.1636287723804Kv7GyMX&_f=index_chan08news_0",
            img: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn.sinaimg.cn%2Fsinakd20210812ac%2F180%2Fw1024h756%2F20210812%2F3acf-a3d90d66339da255e120edf13d32c68f.jpg&refer=http%3A%2F%2Fn.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638879837&t=c87f43859f703ac6ebbf7be92f430c95",
        },
        {
            id: 3,
            name: "今冬有多冷",
            url: "https://www.sohu.com/a/499642459_114731?spm=smpc.news-home.top-news3.1.1636287723804Kv7GyMX&_f=index_chan08news_5",
            img: "https://img2.baidu.com/it/u=3551272000,463636519&fm=26&fmt=auto",
        }
    ]
    return Result
})

Mock.mock("/sys/focusNews/update","put",(res)=>{
    console.log(res.body)
    Result.data = "success"
    return Result
})

Mock.mock("/sys/focusNews/insert","post",(res)=>{
    console.log(res.body)
    Result.data = {
        id: 7
    }
    return Result
})

Mock.mock("/sys/focusNews/delete/1","delete",()=>{
    Result.data = "success"
    Result.code = 200;
    Result.msg = "操作成功"
    return Result
})

Mock.mock("/article/Java/list","get",() => {
    Result.data = [
        {
            id: 1,
            title: "我的第一个 JAVA 程序",
            introduction: "移动操作系统 Android 大部分的代码采用 Java 编程语言编程。",
            img: "https://www.runoob.com/wp-content/uploads/2013/12/java.jpg",
            time: "2021-11-14 15:01:15",
            content: "http://139.196.218.60:9000/article/Centos7%B0%B2%D7%B0Docker.md",
            type: "Java",
            comment: 222,
            heat: 3333
        },
        {
            id: 2,
            title: "我的第一个 JAVA 程序",
            introduction: "移动操作系统 Android 大部分的代码采用 Java 编程语言编程。",
            img: "https://www.runoob.com/wp-content/uploads/2013/12/java.jpg",
            time: "2021-11-14 15:01:15",
            content: "http://139.196.218.60:9000/article/Centos7%B0%B2%D7%B0Docker.md",
            type: "Java",
            comment: 222,
            heat: 3333
        },
        {
            id: 3,
            title: "我的第一个 JAVA 程序",
            introduction: "移动操作系统 Android 大部分的代码采用 Java 编程语言编程。",
            img: "https://www.runoob.com/wp-content/uploads/2013/12/java.jpg",
            time: "2021-11-14 15:01:15",
            content: "http://139.196.218.60:9000/article/Centos7%B0%B2%D7%B0Docker.md",
            type: "Java",
            comment: 222,
            heat: 3333
        }
    ]
    return Result
})

Mock.mock("/article/img/upload","post",(res)=>{
    console.log(res)
    Result.data = 'http://139.196.218.60:9000/self/avatar.png';
    return Result
})

Mock.mock("/article/content/upload","post",(res)=>{
    console.log(res)
    Result.data = 'http://139.196.218.60:9000/self/avatar.png';
    return Result
})

Mock.mock("/article/update","put",(res)=>{
    console.log(res.body)
    Result.data = "success"
    return Result
})

Mock.mock("/article/insert","post",(res)=>{
    console.log(res.body)
    Result.data = {
        id: 7
    }
    return Result
})

Mock.mock("/article/delete/1","delete",()=>{
    Result.data = "success"
    Result.code = 200;
    Result.msg = "操作成功"
    return Result
})

Mock.mock('/sys/promote/list','get',()=>{
    Result.data = [
        {
            id: 1,
            name: '狂神Java',
            url: 'https://space.bilibili.com/95256449/channel/seriesdetail?sid=393820'
        },
        {
            id: 2,
            name: '廖学锋',
            url: 'https://www.liaoxuefeng.com/'
        },
        {
            id: 3,
            name: '编程导航',
            url: 'https://www.code-nav.cn/'
        }
    ]
    return Result
})

Mock.mock('/sys/promote/insert','post',(res)=>{
    console.log(res)
    Result.data = {
        id: 88
    }
    return Result
})

Mock.mock('/sys/promote/update','put',(res)=>{
    console.log(res)
    Result.data = 'success'
    return Result
})

Mock.mock('/sys/promote/delete/1','delete',()=>{
    Result.data = 'success'
    return Result
})


Mock.mock('/user/list','get',()=>{
    Result.data = [
        {
            id: 1,
            name: '狂神Java',
            intro: "上去的路并不拥挤，大多数选择了轻松",
            url: 'https://space.bilibili.com/95256449/channel/seriesdetail?sid=393820',
            avatar: 'http://139.196.218.60:9000/icon/QQ.png'
        },
        {
            id: 2,
            name: '狂神Java22',
            intro: "上去的路并不拥挤，大多数选择了轻松",
            url: 'https://space.bilibili.com/95256449/channel/seriesdetail?sid=393820',
            avatar: 'http://139.196.218.60:9000/icon/QQ.png'
        },
        {
            id: 3,
            name: '狂神Java2222',
            intro: "上去的路并不拥挤，大多数选择了轻松",
            url: 'https://space.bilibili.com/95256449/channel/seriesdetail?sid=393820',
            avatar: 'http://139.196.218.60:9000/icon/QQ.png'
        }
    ]
    return Result
})

Mock.mock('/user/insert','post',(res)=>{
    console.log(res)
    Result.data = {
        id: 88
    }
    return Result
})

Mock.mock('/user/update','put',(res)=>{
    console.log(res)
    Result.data = 'success'
    return Result
})

Mock.mock('/user/delete/1','delete',()=>{
    Result.data = 'success'
    return Result
})

export default Mock;

